﻿/*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
 *~*  16-Oct-2009
 *~*  www.Learning-Leisure.com
 *~*  Project : PB.FBManager                    Namespace : PB.FBManager
 *~*  File : FConnectAPI.cs                         Class : FConnectAPI
 *~*  Author : Pinal Bhatt 
 *~*            self@P-Bhatt.com, www.P-Bhatt.com
 *~*   Version History
 *~*            Last Update Date :     Date 16-Oct-2009       Pinal Bhatt
 *~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*/

using System;

namespace PB.FBManager
{
    /// <summary>
    /// Wrapper on facebook.API
    /// </summary>
    public class FConnectAPI : facebook.API
    {
        #region Constructors

        /// <summary>
        /// Default constructor
        /// </summary>
        public FConnectAPI()
            : base()
        {

        }

        /// <summary>
        /// Creates FConnectAPI object with Application Key and Secret Key 
        /// </summary>
        /// <param name="withFBAppSettings"></param>
        public FConnectAPI(bool withFBAppSettings)
            : base()
        {
            if (withFBAppSettings)
            {
                base.ApplicationKey = FBApp.ApiKey;
                base.Secret = FBApp.SecretKey;
            }
        }


        /// <summary>
        /// Creates FConnectAPI object with Application & Session Information 
        /// </summary>
        /// <param name="withFBAppSettings"></param>
        /// <param name="withFBSessionSettiong"></param>
        public FConnectAPI(bool withFBAppSettings, bool withFBSessionSettings)
            : base()
        {
            if (withFBAppSettings)
            {
                base.ApplicationKey = FBApp.ApiKey;
                base.Secret = FBApp.SecretKey;
            }
            if (withFBSessionSettings)
            {
                FBSession fbSession = new FBSession();
                if (fbSession.IsConnected())
                {
                    base.SessionKey = fbSession.SessionKey;
                    base.uid = fbSession.UserID;
                }
                else
                    throw new Exception("FConnectAPI object cannot be created");
            }
        }
        #endregion
    }
}
